Many computer-based computations involve the processing of very large data sets. Frequently, however, the conclusion to be drawn by the computations, while computationally intensive due to the nature of the calculations and/or the size of the data set, nonetheless yields a simple or straightforward result. For example, in image processing, a code may need to determine whether an image contains a particular shade or shades of gray. Depending on the size of the image and the arrangement of the image data, identifying a particular shade of gray may require millions of computations, but the end result is simply identifying whether the image has a particular shade of gray.
In many cases, such results are needed multiple times. If the data set remains constant, this does not present a problem. Instead of running the calculation algorithm every time the result is needed, programs often compute the answer once and cache that answer for future reference. However, if the data set is ever modified, a cached result may be based on an old version of the data set. Returning to the previous example, suppose a program alters the image after a code has identified whether the image contains a particular shade of gray. Rather than rely on the previously cached result, the code should be made aware that the image was altered so that it may recalculate whether the image contains a particular shade of gray. Therefore, programs containing a data set should ensure that a code accessing the data set should recalculate any cached results if the data set is ever modified.
Notifying a program that the data set has been modified is relatively simple when only one program has access to the data set. But when multiple objects or observers have access to the data set, all with separate cached answers, tracking all of the modifications and observers can be difficult. Thus, what is needed is a mechanism to ensure that cached calculation results of multiple observers of the data set are recalculated if the data set is ever modified, amongst other things.